
//
//  CarWarnCell.swift
//  Automobile
//
//  Created by erkebulan elzhan on 8/25/20.
//  Copyright © 2020 erkebulan elzhan. All rights reserved.
//

import UIKit


final class CarWarnCell: UITableViewCell {

    // MARK: - Outlets

    private lazy var separatorView = CellSeparator()
    
    private lazy var containerView: UIView = {
        let view = UIView()
        view.backgroundColor = .rgb(255, 226, 212)
        view.layer.cornerRadius = 7
        return view
    }()
    
    private lazy var titleText: UILabel = {
        let lbl = UILabel()
        lbl.font = .systemFont(ofSize: 15)
        lbl.numberOfLines = 0
        lbl.textColor = .rgb(255, 111, 41)
        lbl.text = "Приобретая ТС, никогда не отправляйте предоплату"
        return lbl
    }()
    
    private lazy var markIcon: UIImageView = {
        let icon = UIImageView()
        icon.image = UIImage(named: "warn")
        return icon
    }()
    
    // MARK: - Init
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.addViews()
    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}

extension CarWarnCell {
    
    private func addViews () {
        self.contentView.addSubview(separatorView)
        contentView.addSubview(containerView)
        containerView.addSubview(titleText)
        containerView.addSubview(markIcon)
        
        separatorView.snp.makeConstraints { (make) in
            make.leading.trailing.bottom.equalToSuperview()
            make.height.equalTo(20)
        }
        containerView.snp.makeConstraints { (make) in
            make.top.leading.trailing.equalToSuperview().inset(16)
            make.bottom.equalTo(separatorView.snp.top).offset(-16)
        }
        markIcon.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.leading.equalToSuperview().inset(16)
            make.width.height.equalTo(16)
        }
        titleText.snp.makeConstraints { (make) in
            make.trailing.top.bottom.equalToSuperview().inset(16)
            make.leading.equalTo(markIcon.snp.trailing).offset(8)
        }
    }
}


extension CarWarnCell: ConfigurableCell {
    
    func configure(data object: String?, index: Int) {}

    func returnData() -> String? {  return nil }
}
